%% taskA
clear;clc;
A = [1 5 0 0;0 8 3 0;5 0 2 4;9 0 0 1];
S = [3.5 2.5 4.5 1.5]';
%(6)
Id = A*S

%% taskB
G = [1.0 2.2 0 0;0 3.5 0.3 0;9.2 0 2.3 6.9;0.2 0 0 7.3];
C = [0.5 0.3 0 0;0 0.1 0.7 0;4.2 0 7.5 1.2;1.0 0 0 5.6];
S1= [3.5 2.5 4.5 1.5]';

D1 = [1 1 1 1]';
D2 = [1 1 1 1]';
%(4)(5)
IG = G*S1
IC = C*S1
%(7)(8)(9)
R = D1-G*S1
H = D2-C*S1
A = G+0.5*C
%% 
A = [1 5 0 0;0 8 3 0;5 0 2 4;9 0 0 1]
s = sparse(A);
[i,j,k]=find(s);
data = [i';j';k'];
save('./output2.txt','data','-ascii');